<?php
/*********************************************************************************************
										>>VERSION PARA SQL SERVER<<
 Modificaciones:
 Diego V&#65533;squez -- levantar excepciones al detectar error de mysql -- 23/10/2009
 *********************************************************************************************/
 
// metodos gen&#65533;ricos para la base de datos

class DataBase{
	var $serverName;
	var $port;	
	var $username; // Sql username 
	var $password; // Sql password 
	var $db_name; // Database name 
	var $connectionInfo;
	var $link;

	// constructor
	function DataBase($serverName, $port, $db_name, $username, $password){
		$this->serverName = $serverName . ", " . $port;
		$this->port = $port;
		$this->db_name = $db_name;
		$this->username = $username;
		$this->password = $password;
		$this->connectionInfo = array( "Database"=>$this->db_name, "UID"=>$this->username, "PWD"=>$this->password);
		
		// Connect to server and select databse.
		$this->link = sqlsrv_connect( $this->serverName, $this->connectionInfo) or die("No se puede conectar a la base de datos 
		" . $db_name . " En el Servidor: " . $serverName .  " <a href=\"index.php\"> Inicio </a>") ;
		
	}
	
	function Execute($sql){
		// ChromePhp::log("EXECUTE MANAGER PARAMETER SAY: " . $sql);
		$result = sqlsrv_query( $this->link, $sql );

		if( $result === false) {
			die( print_r( sqlsrv_errors(), true) );
		}
		return $result;
	}	
}
?>